//
//  AboutViewController.m
//  LightControl
//
//  Created by CKF on 2025/8/8.
//

#import "AboutViewController.h"
#import "Masonry.h"
#import "AboutTableViewCell.h"
@interface AboutViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)NSArray *dataArray;
@end

@implementation AboutViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"关于";
    self.view.backgroundColor = [UIColor whiteColor];
    _dataArray = @[@{@"title":LocalString(@"版本信息"),@"detail":@"v1.0.0"},
    @{@"title":LocalString(@"版权所有"),@"detail":@"© 2024 TechInnovate.All rigth reserved"},
                   @{@"title":LocalString(@"联系我们"),@"detail":@"Email:",@"phone":@"Phone:"}];
    UIView *headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, 170)];
    headView.backgroundColor = RGB(200, 224, 253);
    _tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
    [self.view addSubview:_tableView];
    [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    [_tableView registerClass:[AboutTableViewCell class] forCellReuseIdentifier:@"AboutTableViewCell"];
    _tableView.backgroundColor = self.view.backgroundColor;
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.tableFooterView = [[UIView alloc]init];
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    _tableView.tableHeaderView = headView;
    _tableView.tableHeaderView.frame = CGRectMake(0, 0, KScreenWidth, 170);
    if (@available(iOS 15.0, *)) {
        _tableView.sectionHeaderTopPadding = 0;
    }
}



-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 2) {
        return 95;
    }else{
        return 70;
    }
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSDictionary *dic = [_dataArray objectAtIndex:indexPath.row];
    AboutTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AboutTableViewCell"];
    cell.titleLabel.text = dic[@"title"];
    cell.detailLabel.text = dic[@"detail"];
    if (indexPath.row < 2) {
        cell.phoneLabel.text = @"";
        cell.phoneLabel.hidden = YES;
    }else{
        cell.phoneLabel.text = dic[@"phone"];
        cell.phoneLabel.hidden = NO;
    }
    return cell;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
